/*     */ package com.infoservice.schedule.generator;
/*     */ 
/*     */ import com.infoservice.schedule.Constant;
/*     */ import com.infoservice.schedule.po.pos.TaskPO;
/*     */ import com.infoservice.schedule.util.TaskUtils;
/*     */ import java.util.Calendar;
/*     */ import java.util.Date;
/*     */ 
/*     */ public class GenWeekTask extends TaskGenerator
/*     */ {
/*     */   public GenWeekTask(TaskPlanInfo tpInfo, TaskPO tk)
/*     */   {
/*  34 */     super(tpInfo, tk);
/*     */   }
/*     */ 
/*     */   public long getDelayTime()
/*     */   {
/*  42 */     Date nextDate = getNextExcTime();
/*  43 */     Calendar cur = TaskUtils.getCalendar();
/*  44 */     return nextDate.getTime() - cur.getTimeInMillis() < Constant.TASK_GEN_AHEAD_TIME ? 0L : nextDate.getTime() - cur.getTimeInMillis() - Constant.TASK_GEN_AHEAD_TIME;
/*     */   }
/*     */ 
/*     */   public long getPeriodTime()
/*     */   {
/*  52 */     return 604800000L;
/*     */   }
/*     */ 
/*     */   public void run()
/*     */   {
/*  60 */     genTask();
/*     */   }
/*     */ 
/*     */   public Date getNextExcTime()
/*     */   {
/*  68 */     Calendar cur = TaskUtils.getCalendar();
/*  69 */     Date planStartTime = null;
/*  70 */     if (this.tk == null) {
/*  71 */       planStartTime = getDate(this.tpInfo.getPlanStart(), this.tpInfo.getPlanPattern());
/*  72 */       if (planStartTime.getTime() >= cur.getTimeInMillis())
/*  73 */         return planStartTime;
/*     */     } else {
/*  75 */       planStartTime = this.tk.getPlanStartTime();
/*  76 */       if (planStartTime.getTime() >= cur.getTimeInMillis())
/*  77 */         return new Date(planStartTime.getTime() + getInterval());
/*     */     }
/*  79 */     long times = (cur.getTimeInMillis() - planStartTime.getTime()) / getInterval();
/*  80 */     times += 1L;
/*  81 */     return new Date(planStartTime.getTime() + times * getInterval());
/*     */   }
/*     */ 
/*     */   public int getIgnoreTimes() {
/*  85 */     Calendar cur = TaskUtils.getCalendar();
/*  86 */     Date planStartTime = null;
/*  87 */     if (this.tk == null) {
/*  88 */       planStartTime = getDate(this.tpInfo.getPlanStart(), this.tpInfo.getPlanPattern());
/*  89 */       if (cur.getTimeInMillis() < planStartTime.getTime()) {
/*  90 */         return 0;
/*     */       }
/*  92 */       long times = (cur.getTimeInMillis() - planStartTime.getTime()) / getInterval();
/*  93 */       return (int)times + 1;
/*     */     }
/*     */ 
/*  96 */     planStartTime = this.tk.getPlanStartTime();
/*  97 */     if (cur.getTimeInMillis() < planStartTime.getTime()) {
/*  98 */       return 0;
/*     */     }
/* 100 */     long times = (cur.getTimeInMillis() - planStartTime.getTime()) / getInterval();
/* 101 */     return (int)times;
/*     */   }
/*     */ 
/*     */   public void setTaskPO(Date planStartTime)
/*     */   {
/* 112 */     if (this.tk == null) {
/* 113 */       this.tk = new TaskPO();
/*     */     }
/* 115 */     this.tk.setPlanStartTime(planStartTime);
/*     */   }
/*     */ 
/*     */   public Date getEndDate()
/*     */   {
/* 123 */     return getDate(this.tpInfo.getPlanEnd(), this.tpInfo.getPlanPattern());
/*     */   }
/*     */ 
/*     */   public Date getStartDate() {
/* 127 */     return getDate(this.tpInfo.getPlanStart(), this.tpInfo.getPlanPattern());
/*     */   }
/*     */   public Date getDate(String hm, String pattern) {
/* 130 */     Calendar date = TaskUtils.getCalendar();
/* 131 */     String[] temp = hm.split(":");
/* 132 */     date.set(11, Integer.parseInt(temp[0]));
/* 133 */     date.set(12, Integer.parseInt(temp[1]));
/* 134 */     if (pattern.equals("W1")) {
/* 135 */       date.set(7, 2);
/*     */     }
/* 137 */     if (pattern.equals("W2")) {
/* 138 */       date.set(7, 3);
/*     */     }
/* 140 */     if (pattern.equals("W3")) {
/* 141 */       date.set(7, 4);
/*     */     }
/* 143 */     if (pattern.equals("W4")) {
/* 144 */       date.set(7, 5);
/*     */     }
/* 146 */     if (pattern.equals("W5")) {
/* 147 */       date.set(7, 6);
/*     */     }
/* 149 */     if (pattern.equals("W6")) {
/* 150 */       date.set(7, 7);
/*     */     }
/* 152 */     if (pattern.equals("W7")) {
/* 153 */       date.set(7, 1);
/*     */     }
/* 155 */     return date.getTime();
/*     */   }
/*     */ 
/*     */   public long getInterval()
/*     */   {
/* 163 */     return 604800000L;
/*     */   }
/*     */ }

/* Location:           D:\Workspace\Work\ASMP_DE\lib\frame3\InfoSchedule_1.0.03.jar
 * Qualified Name:     com.infoservice.schedule.generator.GenWeekTask
 * JD-Core Version:    0.6.0
 */